import React, { Component } from "react";
import { Table, Select } from "antd";
import { accountCate } from "../../config/enums";
const { Option } = Select;

export default class Bonus extends Component {
  state = { selectState: 13, selectPhone: null, orders: [], isLoading: false };
  onSearchPhone = (e) => {
    this.setState({
      selectPhone: e,
    });
    this.getOrders();
  };
  onChangeState = (e) => {
    this.setState({
      selectState: Number(e),
    });
    this.getOrders(e);
  };
  getOrders = async (e) => {
    this.setState({
      isLoading: true,
    });
    const res = await this.http("PayRecord/Spec", {
      Cate: e ? Number(e) : this.state.selectState,
    });
    this.setState({
      orders: res.data.dtos,
      isLoading: false,
    });
  };
  componentDidMount() {
    this.getOrders();
  }
  columns = [
    {
      title: "订单时间",
      dataIndex: "date",
      render: (e) => <div>{this.$dayjs(e).format("YYYY-MM-DD HH:mm:ss")}</div>,
    },
    {
      title: "提现用户",
      dataIndex: "phone",
    },
    {
      title: "分红金额",
      dataIndex: "cost",
    },
    {
      title: "提现账户",
      dataIndex: "accountCate",
      render: (e) => <div>{accountCate[e]}</div>,
    },
    // {
    //   title: "审核状态",
    //   dataIndex: "isChecked",
    //   render: (e) => <div>{e ? "已审核" : "未审核"}</div>,
    // },
  ];
  render() {
    return (
      <div>
        <div className="header" style={{ margin: "20px" }}>
          <Select
            style={{ width: 200, marginRight: "20px" }}
            placeholder="选择订单状态"
            onChange={this.onChangeState}
            defaultValue={"13"}
          >
            <Option value="13">分公司分红</Option>
            <Option value="14">总公司分红</Option>
          </Select>
          {/* <Select
            showSearch
            style={{ width: 200 }}
            placeholder="按用户手机号查找"
            optionFilterProp="children"
            onSearch={this.onSearchPhone}
            filterOption={(input, option) =>
              option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
            }
          ></Select> */}
        </div>
        <Table
          loading={this.state.isLoading}
          rowKey={(data) => data.id}
          columns={this.columns}
          dataSource={this.state.orders}
        />
      </div>
    );
  }
}
